package com.example.back.dao.monthlyCard;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.Map;

@Mapper
public interface MonthlyCardDao {
    @Select("select count(*) from t_monthly_card where userId=#{userId} and #{time} between beginTime and endTime")
    int getMonthlyCardUser(long userId, String time);
    @Select("select * from t_monthly_card where userId=#{userId} and #{time} between beginTime and endTime limit 1")
    Map<String,Object> getUserAllMonthlyCardUser(long userId,String time);

    @Insert("insert into t_monthly_card(userId,beginTime,endTime)values(#{userId},#{beginTime},#{endTime})")
    void insertMonthlyCardUser(long userId,String beginTime,String endTime);

    @Select("select * from t_resources_configs where msgType='MonthlyCard' and msgKey=#{MonthlyCard} limit 1")
    Map<String,Object> getMonthlyCardResourcesConfigs();

    @Update("update t_monthly_card set endTime=#{endTime} where id=#{id}")
    void updateUserMonthlyCard(long userId,long id,String endTime);

}
